package com.arm.service.impl;

import com.arm.dao.ProductTypeMapper;
import com.arm.module.Product;
import com.arm.module.ProductType;
import com.arm.service.ProductBase;
import com.arm.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * Created by Baggio on 2017-3-29.
 */
@Service("productService")
public class ProductServiceImpl extends ProductBase implements ProductService {
@Autowired
    ProductTypeMapper productTypeMapper;
    @Override
    public void modifyProduct(Product product) {
        Long productId = product.getProductId();
        if (productId == null) {
            super.insertProduct(product);
        } else {
            super.updateProduct(product);
        }
    }

    @Override
    public Product getProduct(Map<String, String> map) {

        return productMapper.getProduct(map);
    }


    @Override
    public List<Product> getProductList(Map<String, String> map) {
        return productMapper.getProductList(map);

    }

    @Override
    public List<ProductType> getProductTypeList() {
        return productTypeMapper.getProductTypeList(null);
    }
}
